home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d12
/
v10n18.arc
/
LN1018.ARC
/
NOTEPAD
< prev
next >
Wrap
Text File
|
1991-10-30
|
1KB
|
33 lines
REM Notepad -- demonstrates Shell and SendKeys
Sub MAIN
name$ = "tmp.tmp"
If Files$(name$) <> "" Then ' If file already exists...
QuestionIcon = 32
OkCancel = 1
Ok = -1
' Elsewhere in article we've used the MsgBox statement.
' The line above uses the MsgBox() function, which returns
' the magic number of the button the user pushed.
If MsgBox("Delete " + name$, QuestionIcon + OkCancel) = Ok Then
On Error Goto ErrorTrap ' watch for strange WinWord behavior
Kill name$ ' if user says ok, then delete it
On Error Goto 0 ' reset normal error processing
Else
Goto done ' otherwise do nothing
End If
End If
On Error Goto done
s$ = InputBox$("Type some stuff to send to Notepad")
Shell "notepad" ' run Notepad
Wait = -1 ' wait for Notepad to process keystrokes
SendKeys s$ + "~", Wait ' send the string of text
SendKeys "%FA" + name$ + "~", Wait ' Alt-F A: File Save As...
SendKeys "%FX", Wait ' Alt-F X: File Exit
Goto done
ErrorTrap:
MsgBox "WinWord has problems deleting " + name$ + "." + \
"Please close the file, clear your clipboard, and try again."
done:
End Sub
«MDNM»